package com.hoshiicloud.commissioncalculation.feign.hystrix;

import com.hoshiicloud.commissioncalculation.feign.WithdrawFeignService;
import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.withdraw.param.ContractPlatformParam;
import com.hoshiicloud.withdraw.param.SubscriptionInformatioParam;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author ygd
 * @title: HystrixGoodsFeignFallback
 * @projectName hoshiicloud
 * @description: 商品熔断
 * @date 2019/9/5
 */
@Component
public class HystrixWithdrawFeignFallback implements FallbackFactory<WithdrawFeignService> {

	@Override
	public WithdrawFeignService create(Throwable cause) {
		return new WithdrawFeignService() {
			@Override
			public Response<Boolean> subscriptionInformation(SubscriptionInformatioParam param) {
				return Response.failed(cause.getMessage());
			}

			@Override
			public Response<String> contractPlatform(ContractPlatformParam param) {
				return Response.failed(cause.getMessage());
			}
		};
	}

}
